#include <cstdio>
#define lowbit(x) (x & (-x))
using ll = long long;

const int N = 1e3 + 5;
int n, m;

struct szsz {
  int c[N][N];
  inline void modify(int x, int y, ll v) {
    for (int i = x; i <= n; i += lowbit(i))
      for (int j = y; j <= n; j += lowbit(j)) c[i][j] ^= v;
  }

  inline ll query(int x, int y) {
    ll ans = 0;
    for (int i = x; i > 0; i -= lowbit(i))
      for (int j = y; j > 0; j -= lowbit(j)) ans ^= c[i][j];
    return ans;
  }
} c[5];

inline int id(int x, int y) {
  int rt = 0;
  if (x & 1) rt |= 1;
  if (y & 1) rt |= 2;
  return rt;
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("CF341D Iahub and Xors.in", "r", stdin);
  freopen("CF341D Iahub and Xors.out", "w", stdout);
#endif
#endif

  scanf("%d%d", &n, &m);
  ll v;
  for (int i = 1, x1, y1, x2, y2, opt; i <= m; i++) {
    scanf("%d", &opt);
    if (opt == 1) {
      scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
      ll ans = c[id(x2, y2)].query(x2, y2);
      ans ^= c[id(x2, y1 - 1)].query(x2, y1 - 1);
      ans ^= c[id(x1 - 1, y2)].query(x1 - 1, y2);
      ans ^= c[id(x1 - 1, y1 - 1)].query(x1 - 1, y1 - 1);
      printf("%lld\n", ans);
    } else {
      scanf("%d%d%d%d%lld", &x1, &y1, &x2, &y2, &v);
      c[id(x1, y1)].modify(x1, y1, v);
      c[id(x2 + 1, y1)].modify(x2 + 1, y1, v);
      c[id(x1, y2 + 1)].modify(x1, y2 + 1, v);
      c[id(x2 + 1, y2 + 1)].modify(x2 + 1, y2 + 1, v);
    }
  }
  return 0;
}